/*************************************************************************
	> File Name: P1071.cpp
	> Author: yufangze
	> Mail: 2224590123@qq.com
	> Created Time: 2025-01-08 10:43:39
 ************************************************************************/
#include <iostream>
#include <string>
#include <map>
#include <set>
using namespace std;

int main() {
    string a, b, c;
    cin >> a >> b >> c;
    map<char, char> mp;
    set<char> st;
    bool flag = true;
    for (int i = 0; flag && i < a.size(); i++) {
        if (mp[a[i]] == 0) {
            mp[a[i]] = b[i];
            st.insert(b[i]);
        }
        else if (mp[a[i]] == b[i]) continue;
        else {
            flag = false;
        }
    }
    if (flag == false || st.size() != 26) {
        cout << "Failed" << endl;
    } else {
        for (int i = 0; i < c.size(); i++) {
            cout << mp[c[i]];
        }
        cout << endl;
    }
    return 0;
}
